<?php
/**
 * 材料规格
 * (model)
 */
namespace App\Models\Product;

use Illuminate\Database\Eloquent\Model;

class ProductMaterialSpec extends Model{

    protected $table = 'product_material_spec';

    protected $guarded = [];

    const STATUS_YES = 1; //启用
    const STATUS_NO  = 2; //停用
    public static $_status = [
        self::STATUS_YES => '启用',
        self::STATUS_NO  => '停用',
    ];

    public static function options(){

        $res = self::query()->get()->map(function ($model){
            return collect(['spec' => $model->code.'-'.$model->title,
                'code' => $model->code]);
        });

        return $res->pluck('spec','code');
    }

}
